To Do List

  • add notes for “set up” to give idea of the contents of the document
  • go back and check PSQI for correct columns, summary scores, etc.
  • add variable labels to all summary scores
  • Find missing 73A data
  • Fill in 37A data from PP qualtrics

Set Up

Notes

SPSS File Name: HATCH Syntax for Prenatal Q’s 4.17.21.sps

Packages

library(tidyverse) # for data cleaning
library(here) # to quickly find data files
library(haven) # to manipulate SPSS files and add SPSS-style labels
library(chron) # to manipulate time and date variables
library(sjmisc) # for rowwise functions (row_count function)
library(data.table) # for renaming variables (setnames function)
library(kableExtra) # to print tables more neatly (kbl wrapping function) 

Load Data

df.pn <- read.csv(here("data/qualtrics/Intermediate", "0_pn.democlean.csv")) 

Inventories

AAS: Adult Attachment Scale

Notes

General Notes

  • Collins, 1996 (revised version)
  • Creates mean summary scores
  • Creates three subscales: Close, Depend, Anxiety
  • Creates two alternative subscales: Anxiety and Avoid
  • Higher scores mean…
    • Close: more comfort with intimacy
    • Depend: greater belief that one can depend on others
    • Anxiety: more concerns with being rejected
    • Avoid: greater avoidance of closeness
  • HATCH uses 1996 revised version, not 1990 original version

Scoring Instructions

  • Author’s scoring instructions
  • 1 (not characteristic of me) to 5 (very charasteristic of me)
  • Subscales
    • Close: 1, 6, 8R, 12, 13R, 17R
    • Depend: 2R, 5, 7R, 14, 16R, 18R
    • Anxiety: 3, 4, 9, 10, 11, 15
  • Alternative subscales:
    • Anxiety: 3, 4, 9, 10, 11, 15
    • Avoid: 1R, 2, 5R, 6R, 7, 8. 12R, 16, 17, 18
  • Reverse score: 2, 7, 8, 13, 16, 17, 18
  • Reverse score (avoid): 1, 5, 6, 12
Means from Fernandez & Dufey, 2015

SPSS Syntax Notes

  • Creates three subscales: Close, Depend, Anxiety
  • Note that items & scoring differ from original (Collins & Read, 1990) AAS

Qualtrics Scoring

Scores for Items 1-18

Qualtrics for Items 1-18

Script

Rename AAS columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="AAS_1.pn"):which(colnames(df.pn)=="AAS_18.pn")

# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Reverse code items

# Reverse Code Key
reverse_key <- setNames(c(1:5), 5:1)

# Reverse code questions 2,7,8,13,16,17,18
df.pn <- df.pn %>%
  mutate_at(vars(c(AAS2.pn, AAS7.pn, AAS8.pn, 
                   AAS13.pn, AAS16.pn:AAS18.pn)), 
            ~ recode(., !!!reverse_key))


# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("AAS2.pn", "AAS7.pn", "AAS8.pn",
                             "AAS13.pn","AAS16.pn", "AAS17.pn",  "AAS18.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("AAS2.pn", "AAS7.pn", "AAS8.pn",
                             "AAS13.pn","AAS16.pn", "AAS17.pn",  "AAS18.pn")))

Calculate summary scores

df.pn <- df.pn %>%
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(AAS1.pn:AAS18_r.pn)), as.numeric) %>%
  
  # Calculate subscales
  mutate(AAS_close.pn = round(mean(c(AAS1.pn, AAS6.pn, AAS8_r.pn,
                                  AAS12.pn, AAS13_r.pn, AAS17_r.pn),
                                   na.rm = F), 3),
         AAS_dep.pn = round(mean(c(AAS2_r.pn, AAS5.pn, AAS7_r.pn,
                                  AAS14.pn, AAS16_r.pn, AAS18_r.pn),
                                   na.rm = F), 3),
         AAS_anx.pn = round(mean(c(AAS3.pn, AAS4.pn, AAS9.pn,
                                  AAS10.pn, AAS11.pn, AAS15.pn),
                                   na.rm = F),3)) %>%

  
  # Move the subscales so they come immediately after the measures
  relocate(c(AAS_close.pn:AAS_anx.pn), .after = AAS18_r.pn) 

Print

Moms

CoupleID AAS1.pn AAS2_r.pn AAS3.pn AAS4.pn AAS5.pn AAS6.pn AAS7_r.pn AAS8_r.pn AAS9.pn AAS10.pn AAS11.pn AAS12.pn AAS13_r.pn AAS14.pn AAS15.pn AAS16_r.pn AAS17_r.pn AAS18_r.pn AAS_close.pn AAS_dep.pn AAS_anx.pn
20 1 1 5 3 1 3 1 2 1 1 4 4 4 1 5 1 1 1 2.500 1.000 3.167
2 2 4 1 4 1 2 4 2 1 2 1 3 4 4 4 2 3 5 2.667 3.333 2.167
55 4 4 1 4 2 2 5 5 1 4 1 5 5 5 1 5 5 5 4.333 4.333 2.000
75 4 2 1 1 4 2 5 4 1 1 1 5 5 4 1 5 4 5 4.000 4.167 1.000
52 4 2 1 1 4 5 5 5 1 1 1 4 3 5 2 4 3 5 4.000 4.167 1.167
12 2 1 3 4 1 2 2 2 4 5 4 2 2 2 5 1 1 1 1.833 1.333 4.167

Dads

CoupleID AAS1.pn AAS2_r.pn AAS3.pn AAS4.pn AAS5.pn AAS6.pn AAS7_r.pn AAS8_r.pn AAS9.pn AAS10.pn AAS11.pn AAS12.pn AAS13_r.pn AAS14.pn AAS15.pn AAS16_r.pn AAS17_r.pn AAS18_r.pn AAS_close.pn AAS_dep.pn AAS_anx.pn
65 4 2 1 2 2 2 4 4 1 2 2 4 4 4 2 2 5 2 3.833 2.667 1.667
4 4 2 1 1 2 4 5 5 1 1 2 4 4 4 2 2 3 4 4.000 3.167 1.333
18 3 4 2 2 4 4 4 4 1 2 2 4 3 4 3 4 2 3 3.333 3.833 2.000
10 3 3 1 1 3 3 3 5 1 2 1 4 3 4 3 5 5 5 3.833 3.833 1.500
43 5 2 1 1 2 3 2 4 1 4 1 4 4 2 1 2 5 2 4.167 2.000 1.500
9 2 2 3 3 3 3 2 2 5 5 4 2 3 4 4 2 1 2 2.167 2.500 4.000

BDI: Beck Depression Inventory

Notes

General Notes

  • Beck, 1996
  • Create sum score of 21 items
  • Does not create any subscales
  • Higher values indicate more severe depression
  • HATCH study removed item 9 (suicidality) for IRB purposes when administering the BDI

Scoring Instructions

Items

Score Ranges

  • Likert scales ranging from 0 to 3
Means from Gomes-Oliveria et al., 2012

SPSS Syntax Notes

  • Renaming the items to make it easier for us
  • Let’s assign variable labels so that we don’t have to go back to the paper questionnaire to know what each item was saying
  • Recoding the variables so that the bottom value is 0
  • Now everything is ready to be scored; we have to be careful to list the correct variables since there are three versions of 16 and 18

Qualtrics Scoring

Scoring for Items 1-15, 17, 19-20

Scoring for Item 16

Scoring for Item 18

Qualtrics Items 1-5

Qualtrics Items 6-11

Qualtrics Items 12-16

Qualtrics Items 17-21

Script

Rename BDI columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="BDI1_Sad.pn"):which(colnames(df.pn)=="BDI21_Sex.pn")

# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("BDI", c(1:8, 10:21), ".pn", sep = ""))

Recode item scores

df.pn <- df.pn %>%
# Code Items 1-15, 17, 19-21
  mutate_at(vars(c(BDI1.pn:BDI15.pn, BDI17.pn, BDI19.pn:BDI21.pn)), 
            ~ recode(., 
                        '1' = '0',
                        '2' = '1',
                        '3' = '2',
                        '4' = '3')) %>%
  
  # Code Items 16, 18
  mutate_at(vars(c(BDI16.pn, BDI18.pn)), 
            ~ recode(., 
                        '1' = '0',
                        '2' = '1',
                        '3' = '1',
                        '4' = '2',
                        '5' = '2',
                        '6' = '3',
                        '7' = '3'))

Calculate summary scores

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(BDI1.pn:BDI21.pn)), as.numeric) %>%
  
  # Calculate total score
  mutate(BDI_tot.pn = sum(c_across(BDI1.pn:BDI21.pn))) %>%
  
  # Move the total score so they come immediately after the measures
  relocate(BDI_tot.pn, .after = BDI21.pn) 

BFI: Big Five Inventory (BFI)

Notes

General Notes

  • John, 1991

Scoring Instructions

SPSS Syntax Notes

  • First Reverse score
  • Then create scale scores

Qualtrics Notes

  • Items are in the same order as scoring instructions
  • Item responses are coded the same as scoring instructions

Script

Rename BFI columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="BFI_2_1.pn"):which(colnames(df.pn)=="BFI_2_44.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "_2_", replacement = "", x = colnames(df.pn[,cols])))

Reverse code item scores

# Reverse Code Key
reverse_key <- setNames(c(1:5), 5:1)

# Reverse Score Q's 1, 3, 6
df.pn <- df.pn %>%
  mutate_at(vars(c(BFI6.pn, BFI21.pn, BFI31.pn,
                   BFI2.pn, BFI12.pn, BFI27.pn, BFI37.pn,
                   BFI8.pn, BFI18.pn, BFI23.pn, BFI43.pn, 
                   BFI9.pn, BFI24.pn, BFI34.pn, 
                   BFI35.pn, BFI41.pn)),
            ~ recode(., !!!reverse_key))

# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("BFI6.pn", "BFI21.pn", "BFI31.pn",
                             "BFI2.pn", "BFI12.pn", "BFI27.pn", "BFI37.pn",
                             "BFI8.pn", "BFI18.pn", "BFI23.pn", "BFI43.pn", 
                             "BFI9.pn", "BFI24.pn", "BFI34.pn", 
                             "BFI35.pn", "BFI41.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("BFI6.pn", "BFI21.pn", "BFI31.pn",
                             "BFI2.pn", "BFI12.pn", "BFI27.pn", "BFI37.pn",
                             "BFI8.pn", "BFI18.pn", "BFI23.pn", "BFI43.pn", 
                             "BFI9.pn", "BFI24.pn", "BFI34.pn", 
                             "BFI35.pn", "BFI41.pn")))

Calculate summary scores

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(BFI1.pn:BFI44.pn)), as.numeric) %>%
  
  # Calculate total scores
  mutate(BFI_ext.pn = round(mean(c(BFI1.pn, BFI6_r.pn, BFI11.pn, BFI16.pn,
                            BFI21_r.pn, BFI26.pn, BFI31_r.pn, BFI36.pn), 
                          na.rm = T), 3),
         BFI_agr.pn = round(mean(c(BFI2_r.pn, BFI7.pn, BFI12_r.pn, BFI17.pn, 
                            BFI22.pn, BFI27_r.pn, BFI32.pn, BFI37_r.pn, BFI42.pn),
                          na.rm = T), 3),
         BFI_con.pn = round(mean(c(BFI3.pn, BFI8_r.pn, BFI13.pn, BFI18_r.pn, 
                            BFI23_r.pn, BFI28.pn, BFI33.pn, BFI38.pn, BFI43_r.pn),
                          na.rm = T), 3),
         BFI_neur.pn = round(mean(c(BFI4.pn, BFI9_r.pn, BFI14.pn, BFI19.pn,
                            BFI24_r.pn, BFI29.pn, BFI34_r.pn, BFI39.pn), na.rm = T), 3),
         BFI_open.pn = round(mean(c(BFI5.pn, BFI10.pn, BFI15.pn, BFI20.pn, BFI25.pn,
                             BFI30.pn, BFI35_r.pn, BFI40.pn, BFI41_r.pn, BFI44.pn),
                           na.rm = T), 3)
         ) %>%
  
  # Move the summmary scores so they come immediately after the measures
  relocate(c(BFI_ext.pn, BFI_agr.pn, BFI_con.pn, BFI_neur.pn, BFI_open.pn), 
           .after = BFI44.pn)

Clean up summary scores

df.pn <- df.pn %>%
  mutate(across(c(BFI_ext.pn:BFI_open.pn), ~na_if(., "NaN"))) 

COPE: Brief Cope

Notes

General Notes

  • Carver, 2007

Scoring Instructions

SPSS Syntax Note

  • Comprised of 14 2-item subscales indicative of different coping strategies.

Qualtrics Scoring

Script

Rename COPE columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="COPE_1.pn"):which(colnames(df.pn)=="COPE_28.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Calculate summary scores

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(COPE1.pn:COPE28.pn)), as.numeric) %>%
  
  # Calculate total scores/subscales
  mutate(COPE_dist.pn = sum(c(COPE1.pn, COPE19.pn)), 
         COPE_act.pn = sum(c(COPE2.pn, COPE7.pn)),
         COPE_den.pn = sum(c(COPE3.pn, COPE8.pn)),
         COPE_sub.pn = sum(c(COPE4.pn, COPE11.pn)),
         COPE_emo.pn = sum(c(COPE5.pn, COPE15.pn)),
         COPE_inst.pn = sum(c(COPE10.pn, COPE23.pn)),
         COPE_diseng.pn = sum(c(COPE6.pn, COPE16.pn)),
         COPE_vent.pn = sum(c(COPE9.pn, COPE21.pn)),
         COPE_reframe.pn = sum(c(COPE12.pn, COPE17.pn)),
         COPE_plan.pn = sum(c(COPE14.pn, COPE25.pn)),
         COPE_hum.pn = sum(c(COPE18.pn, COPE28.pn)),
         COPE_acc.pn = sum(c(COPE20.pn, COPE24.pn)),
         COPE_rel.pn = sum(c(COPE22.pn, COPE27.pn)),
         COPE_blame.pn = sum(c(COPE13.pn, COPE26.pn))
         ) %>%
  
  # Move the total score/subscales so they come immediately after the measures
  relocate(c(COPE_dist.pn:COPE_blame.pn), .after = COPE28.pn)

DAS: Dyadic Adjustment Scale

Notes

General Notes

  • Spanier, et al.
  • Higher scores mean healthier relationship
  • Reverse code items 16, 17, 20, 21, 21, 29, 30

Scoring Instructions

Author’s scoring instructions

SPSS Syntax Notes

  • This syntax generates four subscales (consensus, affective expression, satisfaction, and cohesion) and a total sum score
  • Original scales range from 0-5; current version is 5-point (1-5)
  • Maintained 5 as top of scale, making lowest possible score = 30, highest = 152

Qualtrics Scoring

  • Items 1-15: scored 1 (always agree) to 6 (always disagree)
  • Items 16-22: scored 1 (all the time) to 6 (never)
  • Item 23: scored 1 (every day) to 5 (never)
  • Item 24: scored 1 (all of them) to 5 (none of them)
  • Items 25-28: scored 1 (never) to 6 (more often than once a day)
  • Items 29-30: scored 1 (yes) and 2 (no)
  • Item 31: scored 1 (extremely unhappy) to 7 (perfect)
  • Item 32: scored 1 (I desperately want for my relationship to succeed…) to 6 (My relationship can never succeed…)

Script

Rename DAS columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="DAS1.15_1.pn"):which(colnames(df.pn)=="DAS.32.pn")

# Set New Names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("DAS", 1:32, ".pn", sep = ""))

Recode DAS values according to author scoring instructions

df.pn <- df.pn %>%
# Code Items 1-15
  mutate_at(vars(c(DAS1.pn:DAS15.pn)), 
            funs(recode(., 
                        '1' = '5',
                        '2' = '4',
                        '3' = '3',
                        '4' = '2',
                        '5' = '1',
                        '6' = '0'))) %>%
  
  # Recode Items 16, 17, 20, 21, 22
  mutate_at(vars(c(DAS16.pn, DAS17.pn, 
                   DAS20.pn, DAS21.pn, DAS22.pn)), 
            funs(recode(., 
                        '1' = '0',
                        '2' = '1',
                        '3' = '2',
                        '4' = '3',
                        '5' = '4',
                        '6' = '5'))) %>%
  
  # Recode Items 18, 19
  mutate_at(vars(c(DAS18.pn:DAS19.pn)), 
            funs(recode(., 
                        '1' = '5',
                        '2' = '4',
                        '3' = '3',
                        '4' = '2',
                        '5' = '1',
                        '6' = '0'))) %>%
  
  # Recode Items 23-24
  mutate_at(vars(c(DAS23.pn:DAS24.pn)), 
            funs(recode(., 
                        '1' = '4',
                        '2' = '3',
                        '3' = '2',
                        '4' = '1',
                        '5' = '0'))) %>%
  
  # Recode Items 25-28
  mutate_at(vars(c(DAS25.pn:DAS28.pn)), 
            funs(recode(., 
                        '1' = '0',
                        '2' = '1',
                        '3' = '2',
                        '4' = '3',
                        '5' = '4',
                        '6' = '5'))) %>%
  
  # Recode Items 29, 30 
  mutate_at(vars(c(DAS29.pn:DAS30.pn)), 
            funs(recode(., 
                        '1' = '0',
                        '2' = '1'))) %>%
  
  # Recode Item 31
  mutate_at(vars(c(DAS31.pn)), 
            funs(recode(., 
                        '1' = '0',
                        '2' = '1',
                        '3' = '2',
                        '4' = '3',
                        '5' = '4',
                        '6' = '5',
                        '7' = '6'))) %>%
  
  # Recode Item 32
  mutate_at(vars(c(DAS32.pn)), 
            funs(recode(., 
                        '1' = '5',
                        '2' = '4',
                        '3' = '3',
                        '4' = '2',
                        '5' = '1',
                        '6' = '0')))
## Warning: `funs()` was deprecated in dplyr 0.8.0.
## ℹ Please use a list of either functions or lambdas:
## 
## # Simple named list: list(mean = mean, median = median)
## 
## # Auto named with `tibble::lst()`: tibble::lst(mean, median)
## 
## # Using lambdas list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))

Rename Reverse-Coded DAS Items 16, 17, 20, 21, 22, 29, 30

# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("DAS16.pn", "DAS17.pn", "DAS20.pn", "DAS21.pn", 
                             "DAS22.pn", "DAS29.pn", "DAS30.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("DAS16.pn", "DAS17.pn", "DAS20.pn", "DAS21.pn", 
                             "DAS22.pn", "DAS29.pn", "DAS30.pn")))

Calculate summary scores

df.pn <- df.pn %>%
  
  # First, make sure R knows to treat DAS values as numbers
  mutate_at(vars(c(DAS1.pn:DAS32.pn)), as.numeric)%>% 
  
  # Then tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Calculate the summary scores 
  mutate(DAS_con.pn = sum(c(c_across(DAS1.pn:DAS3.pn), DAS5.pn, c_across(DAS7.pn:DAS15.pn)), na.rm = T),
         DAS_sat.pn = sum(c(c_across(DAS16_r.pn:DAS23.pn), c_across(DAS31.pn:DAS32.pn)), na.rm = T),
         DAS_coh.pn = sum(c_across(DAS24.pn:DAS28.pn), na.rm = T),
         DAS_aff.pn = sum(c(DAS4.pn, DAS6.pn, c_across(DAS29_r.pn:DAS30_r.pn)), na.rm = T),
         DAS_tot.pn = sum(c_across(DAS1.pn:DAS32.pn), na.rm = T)) %>%
  
    # Finally, move the sum scores so that they come immediately after the measures
  relocate(c(DAS_con.pn, DAS_sat.pn, DAS_coh.pn, DAS_aff.pn, DAS_tot.pn), .after = DAS32.pn) 

ECR: Experiences in Close Relationships—Revised

Notes

General Notes

  • Fraley, Waller, and Brennan, 2000
  • Revised Version

Scoring Instructions

  • Authors’ scoring instructions
  • Reverse score items 9, 11, 20, 22, 26, 27, 28, 29, 30, 31, 33, 34, 35, and 36
  • 7-point Likert from 1 (strongly disagree) to 7 (strongly agree)
  • Anxiety = mean of 1-18
  • Avoidance = mean of 19-36

SPSS Syntax Note

  • Revised version (38 items)
  • The syntax excludes one participant who is missing a single item.
    • If you want to include him/her, change the COMPUTE syntax to use “MEAN” rather than simply calculating the mean.
  • The two subscales of the ECR-R are Attachment-Related Anxiety and Attachment-Related Avoidance.
  • Reversed 9, 11, 20, 22, 26, 28, 29, 30, 31, 33, 34, 35, 36
  • Anxiety = mean(1:18)
  • Avoidance = mean(19:36)

Qualtrics Scoring

Script

Rename ECR columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="ECR.R_1.pn"):which(colnames(df.pn)=="ECR.R_36.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = ".R_", replacement = "", x = colnames(df.pn[,cols])))

Reverse Code Items

# Reverse Code Key
reverse_key <- setNames(c(1:7), 7:1)

# Reverse Score Q's 9, 11, 20, 22, 26, 27, 28, 29, 30, 31, 33, 34, 35, and 36
df.pn <- df.pn %>%
  mutate(across(c(ECR9.pn, ECR11.pn, ECR20.pn, ECR22.pn,
                  ECR26.pn:ECR31.pn, 
                  ECR33.pn:ECR36.pn),
            ~ recode(., !!!reverse_key)))

# Mark reversed scores with `_r`
setnames(x = df.pn, 
         old = c("ECR9.pn", "ECR11.pn", "ECR20.pn", 
                 "ECR22.pn", "ECR26.pn", "ECR27.pn", 
                 "ECR28.pn", "ECR29.pn", "ECR30.pn", 
                 "ECR31.pn", "ECR33.pn", "ECR34.pn", 
                 "ECR35.pn", "ECR36.pn"), 
         new = gsub(pattern = ".pn", 
                    replacement = "_r.pn", 
                    x = c("ECR9.pn", "ECR11.pn", "ECR20.pn", 
                 "ECR22.pn", "ECR26.pn", "ECR27.pn", 
                 "ECR28.pn", "ECR29.pn", "ECR30.pn", 
                 "ECR31.pn", "ECR33.pn", "ECR34.pn", 
                 "ECR35.pn", "ECR36.pn")))

Calculate summary scores

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(ECR1.pn:ECR36_r.pn)), as.numeric) %>%
  
  # Calculate total scores/subscales
  mutate(ECR_anx.pn = round(mean(c_across(ECR1.pn:ECR18.pn), na.rm = T), 3), 
         ECR_avoid.pn = round(mean(c_across(ECR19.pn:ECR36_r.pn), na.rm = T), 3)) %>%
  
  # Move the total score/subscales so they come immediately after the measures
  relocate(c(ECR_anx.pn, ECR_avoid.pn), .after = ECR36_r.pn)

IRI: Interpersonal Reactivity Index

Notes

General Notes

  • Davis, 1980
  • In the original SPSS syntax, we took the means to get subscales; however, the author summed scores to get subscales
  • I didn’t mean-replace missing scores, but there were only two:
    • one item from the pt scale is missing for dad #79
    • one item from the ec scale is missing for dad #11

Scoring Instructions

Author’s scoring instructions

  • Reverse codes: 3, 4, 7, 12, 13, 14, 15, 18, 19
  • Four subscales and no overall summary score
    • Perspective taking (pt)
    • Fantasy (fs)
    • Empathic Concerns (ec)
    • Personal Distress (pd)
Means from 1980 Paper

SPSS Syntax Notes

  • variable labels a bit off.
    • For subjects 1-18, responses are on a scale of 1-5 (1, 2, 3, 4, 5).
    • For subjects 19-100, responses are missing the “2” and are answered as 1, 3, 4, 5, 6.
    • Let’s correct and bring them into synchrony with the published measure (0-4)
  • then reverse code the negative items

Qualtrics Scoring

  • Participants 1-5 are missing
  • Participants 6-17 are on a scale of 1-5 (1, 2, 3, 4, 5)
  • Participants 18-100 are missing the “2” and are answered as 1, 3, 4, 5, 6.
Qualtrics Scores for Participants 18-100

Script

Rename IRI columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="IRI_1.pn"):which(colnames(df.pn)=="IRI_28.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Recode item scores

df.pn <- df.pn %>%
  
  # Recode scoring for participants 18-100 so that it matches 1-17
  mutate(CoupleID = as.numeric(CoupleID)) %>% #tell R to treat Couple ID as a number
  mutate_at(vars(c(IRI1.pn:IRI28.pn)), 
            ~ifelse(CoupleID > 17 & .>=3, .-1, .)) %>%
  mutate(CoupleID = as.factor(CoupleID)) %>% #tell R to treat Couple ID as a factor again
  
  # Recode all participants to match author scoring instructions
  mutate_at(vars(c(IRI1.pn:IRI28.pn)), 
            funs(recode(., 
                        '1' = '0',
                        '2' = '1',
                        '3' = '2',
                        '4' = '3',
                        '5' = '4'))) 

Reverse code items

# Reverse Code Key
reverse_key <- setNames(c(0:4), 4:0)


df.pn <- df.pn %>%
  
  # Reverse code questions 3, 4, 7, 12, 13, 14, 15, 18, 19
  mutate_at(vars(c(IRI3.pn, IRI4.pn, IRI7.pn, 
                   IRI12.pn:IRI15.pn, IRI18.pn, IRI19.pn)), 
            funs(recode(., !!!reverse_key)))


# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("IRI3.pn", "IRI4.pn", "IRI7.pn", 
                             "IRI12.pn", "IRI13.pn", "IRI14.pn", 
                             "IRI15.pn", "IRI18.pn", "IRI19.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("IRI3.pn", "IRI4.pn", "IRI7.pn", 
                             "IRI12.pn", "IRI13.pn", "IRI14.pn", 
                             "IRI15.pn", "IRI18.pn", "IRI19.pn")))

Calculate summary scores

df.pn <- df.pn %>%
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that IRI scores are numeric
  mutate_at(vars(c(IRI1.pn:IRI28.pn)), as.numeric) %>%
  
  # Calculate summary scores 
  mutate(IRI_fs.pn = sum(c(IRI1.pn, IRI5.pn, IRI7_r.pn, 
                                     IRI12_r.pn, IRI16.pn, IRI23.pn, IRI26.pn),
                                   na.rm = F),
         IRI_pt.pn = sum(c(IRI3_r.pn, IRI8.pn, IRI11.pn, 
                                     IRI15_r.pn, IRI21.pn, IRI25.pn, IRI28.pn),
                                   na.rm = F), 
         IRI_ec.pn = sum(c(IRI2.pn, IRI4_r.pn, IRI9.pn, 
                                     IRI14_r.pn, IRI18_r.pn, IRI20.pn, IRI22.pn),
                                   na.rm = F),
         IRI_pd.pn = sum(c(IRI6.pn, IRI10.pn, IRI13_r.pn, 
                                     IRI17.pn, IRI19_r.pn, IRI24.pn, IRI27.pn),
                                   na.rm = F)) %>%
  
  # Finally, move the summary scores so that they come immediately after the measures
  relocate(c(IRI_fs.pn, IRI_pt.pn, IRI_ec.pn, IRI_pd.pn), .after = IRI28.pn)

ISS: Index of Sexual Satisfaction

Notes

General Notes

  • Hudson, 1981 or 1992 or 1993?
  • There are several versions. It seems like the difference is the Likert scale, but the items stay the same.
  • I couldn’t find a 1992 version, which was the one listed in the “HATCH measures” word doc, but the 1993 version seems to match in all respects

SPSS Syntax Note

  • None

Qualtrics Scoring

Script

Rename ISS columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="ISS_1.pn"):which(colnames(df.pn)=="ISS_25.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Reverse score

# Reverse Code Key
reverse_key <- setNames(c(1:7), 7:1)

# Reverse Score Q's 1, 2, 3, 9, 10, 12, 16, 17, 19, 21, 22, 23
df.pn <- df.pn %>%
  mutate(across(c(ISS1.pn, ISS2.pn, ISS3.pn,
                  ISS9.pn, ISS10.pn, ISS12.pn,
                  ISS16.pn, ISS17.pn, ISS19.pn, 
                  ISS21.pn, ISS22.pn, ISS23.pn),
            ~ recode(., !!!reverse_key)))

# Mark reversed scores with `_r`
setnames(x = df.pn, 
         old = c("ISS1.pn", "ISS2.pn", "ISS3.pn",
                  "ISS9.pn", "ISS10.pn", "ISS12.pn",
                  "ISS16.pn", "ISS17.pn", "ISS19.pn", 
                  "ISS21.pn", "ISS22.pn", "ISS23.pn"), 
         new = gsub(pattern = ".pn", 
                    replacement = "_r.pn", 
                    x = c("ISS1.pn", "ISS2.pn", "ISS3.pn",
                  "ISS9.pn", "ISS10.pn", "ISS12.pn",
                  "ISS16.pn", "ISS17.pn", "ISS19.pn", 
                  "ISS21.pn", "ISS22.pn", "ISS23.pn")))

Calculate summary scores

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(ISS1_r.pn:ISS25.pn)), as.numeric) %>%
  
  # Calculate total score
  mutate(ISS_tot.pn = sum(c_across(ISS1_r.pn:ISS25.pn), na.rm = T)) %>%
  
  # Recode 0 values as NA
  mutate(ISS_tot.pn = na_if(ISS_tot.pn, 0)) %>%
  
  # Move the total score so they come immediately after the items
  relocate(ISS_tot.pn, .after = ISS25.pn)

LAPR: Life Attitudes Profile—Revised

Notes

General Notes

  • Erci, 2008; Reker & Peacock, 1981
  • six dimensions: purpose, coherence, choice or responsibleness, death acceptance, existential vacuum, and goal-seeking
  • two composite scores, but only the first is measured by the HATCH study: Personal Meaning Index (made up of the purpose and coherence dimensions)
  • usually made up of 48 items
  • HATCH study only uses 16 (questions that make up purpose and cohesion dimensions)

Scoring Instructions

LAP-R Likert Scale (from Erci)

LAP-R Subscales (from Erci)

Item 16
  • Erci removed item 16 (“I have a philosophy of life that gives my existence significance”) from the coherence scale because of inadequate factor loadings

  • Confirmation of item 16’s wording can be found here

SPSS Syntax Note

  • reverse score all items
  • sum all items for personal meaning index
  • sum 1, 2, 3, 7, 8, 11, 13, 16 for “Purpose”
  • sum 4, 5, 6, 9, 10, 12, 14, 15 for “Coherence”

Qualtrics Scoring

Qualtrics Scores

Qualtrics Questions

Script

Rename LAP-R columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="LAP.R_1.pn"):which(colnames(df.pn)=="LAP.R_16.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("LAPR",
                     c(1, 2, 5, 7, 12, 16,
                       18, 26, 27, 29, 31, 35, 
                       37, 38, 46, 48), 
                     ".pn", sep = ""))

Reverse score items

# Reverse Code Key
reverse_key <- setNames(c(1:7), 7:1)

# Reverse Score All Items
df.pn <- df.pn %>%
  mutate(across(c(LAPR1.pn:LAPR48.pn),
            ~ recode(., !!!reverse_key)))

Calculate summary scores

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(LAPR1.pn:LAPR48.pn)), as.numeric) %>%
  
  # Calculate total scores/subscales
  mutate(LAPR_pur.pn = sum(c(LAPR1.pn, LAPR2.pn, LAPR5.pn, LAPR18.pn, 
                              LAPR26.pn, LAPR31.pn, LAPR37.pn, LAPR48.pn)),
         LAPR_coh.pn = sum(c(LAPR7.pn, LAPR12.pn, LAPR16.pn, LAPR27.pn, 
                             LAPR29.pn, LAPR35.pn, LAPR38.pn, LAPR46.pn)),
         LAPR_pmi.pn = sum(c_across(LAPR1.pn:LAPR48.pn)))%>%
         
  
  # Move the total score/subscales so they come immediately after the measures
  relocate(c(LAPR_pur.pn, LAPR_coh.pn, LAPR_pmi.pn), .after = LAPR48.pn)

LEC: Life Events Checklist

Notes

SPSS Syntax Notes

  • note that our latest version only goes up to 15;
    • old syntax is greyed out, use newer syntax for downloads with the 1.26.2018 q (Couples 64-100) and later first
  • change LEC missing data to zero.
  • Then, compute the means for stressful life events that happened to the participant, and life events that happened or were witnessed.

Qualtrics Scoring

LEC Questions Before Couple 65

LEC Scoring Before Couple 65

LEC Questions After Couple 65

LEC Scoring After Couple 65

Scoring Information

LEC Scoring Procedures from VA Website

Script

Rename LEC columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="LEC_1.pn"):which(colnames(df.pn)=="LEC_17.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Calculate summary scores

# Calculate Summary Variables
df.pn <- df.pn %>%
  
  # Tell R that we want to take the mean across a row
  rowwise() %>% 
  
  # Tell R that LEC scores are categorical
  mutate(across(starts_with("LEC"), as.factor)) %>%
  
  # Tell R that Couples 1-48 had 17 questions & Couples 49-100 had 15 questions 
  mutate(nquestions = ifelse(as.numeric(CoupleID) < 49, 17, 15)) %>%
  
  # Count Occurrence of each answer type (ignoring answers 3, 4, 5)
  row_count(LEC1.pn:LEC17.pn, count = "1", var = "LEC_count_1", append = T) %>%
  row_count(LEC1.pn:LEC17.pn, count = "1,3", var = "LEC_count_1.3", append = T) %>%
  row_count(LEC1.pn:LEC17.pn, count = "1,2", var = "LEC_count_1.2", append = T) %>% 
  row_count(LEC1.pn:LEC17.pn, count = "1,2,3", var = "LEC_count_1.2.3", append = T) %>% 
  row_count(LEC1.pn:LEC17.pn, count = "2", var = "LEC_count_2", append = T) %>%
  row_count(LEC1.pn:LEC17.pn, count = "2,3", var = "LEC_count_2.3", append = T) %>%
  
  # Calculate Mom Mean Scores (take mean rather than sum because not all parents answered the same number of questions)
  mutate(LEC_hap.pn = round(sum(across(starts_with("LEC_count_1")))/nquestions,2)) %>%
  mutate(LEC_wit.pn = round(sum(LEC_count_2, LEC_count_2.3)/nquestions, 2)) %>%
  mutate(LEC_hapwit.pn = round(sum(across(starts_with("LEC_count")))/nquestions,2)) %>%

  # Remove new helper columns
  select(-starts_with("LEC_count"), -nquestions) %>%
  
  # Finally, move the summary scores so that they come immediately after the measures
  relocate(c(LEC_hap.pn:LEC_hapwit.pn), .after = LEC17.pn)

LES: Life Experiences Survey

Notes

General Notes

  • Sarason et al., 1978
  • Only available for participants 1 through 53

Scoring Instructions

  • Author’s Scoring Instructions
  • The original measure has 57 items, the revised measure we have on file has 37 items; the Qualtrics measure has 20 items (22 total; but some are gendered)
  • There seemed to be some weird stuff going on where parents would rate the event’s impact even if it hadn’t happened in the last year.
    • To account for the scale’s intended purpose, we’ve recoded all impact scores as NA when happened = 0
Subscale scoring instructions

Means from 1978 paper Paper

SPSS Syntax Note

  • None: was not included in the SPSS syntax file

Qualtrics Scoring

Coded values

Qualtrics items

Script

Rename LES columns

Happened
# Get Column Numbers
cols <- which(colnames(df.pn)=="LES.1_1.pn"):which(colnames(df.pn)=="LES.1_22.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("LES", 1:22, "_hap.pn", sep = ""))
Impact
# Get Column Numbers
cols <- which(colnames(df.pn)=="LES.2_1.pn"):which(colnames(df.pn)=="LES.2_22.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("LES", 1:22, "_impact.pn", sep = ""))

Recode LES scores

df.pn <- df.pn %>%
# Re-code happened items
  mutate_at(vars(c(LES1_hap.pn:LES22_hap.pn)), 
            ~ recode(., 
                     '1' = '1',
                     '2' = '0')) %>%
  # Re-code impact items
  mutate_at(vars(c(LES1_impact.pn:LES22_impact.pn)), 
            ~ recode(., 
                     '1' = '-3',
                     '2' = '-2',
                     '3' = '-1', 
                     '4' = '0',
                     '5' = '1', 
                     '6' = '2',
                     '7' = '3')) 

Recode impact scores when happened = 0

df.pn <- df.pn %>%
  
  # Tell R to treat columns as numeric
  mutate_at(vars(c(LES1_hap.pn:LES22_impact.pn)), as.numeric) %>%
  
  mutate(LES1_impact.pn = ifelse(LES1_hap.pn==1, LES1_impact.pn, NA),
         LES2_impact.pn = ifelse(LES2_hap.pn==1, LES2_impact.pn, NA),
         LES3_impact.pn = ifelse(LES3_hap.pn==1, LES3_impact.pn, NA),
         
         LES4_impact.pn = ifelse(LES4_hap.pn==1, LES4_impact.pn, NA),
         LES5_impact.pn = ifelse(LES5_hap.pn==1, LES5_impact.pn, NA),
         LES6_impact.pn = ifelse(LES6_hap.pn==1, LES6_impact.pn, NA), 
         
         LES7_impact.pn = ifelse(LES7_hap.pn==1, LES7_impact.pn, NA),
         LES8_impact.pn = ifelse(LES8_hap.pn==1, LES8_impact.pn, NA),
         LES9_impact.pn = ifelse(LES9_hap.pn==1, LES9_impact.pn, NA),
         
         LES10_impact.pn = ifelse(LES10_hap.pn==1, LES10_impact.pn, NA),
         LES11_impact.pn = ifelse(LES11_hap.pn==1, LES11_impact.pn, NA),
         LES12_impact.pn = ifelse(LES12_hap.pn==1, LES12_impact.pn, NA),
         
         LES13_impact.pn = ifelse(LES13_hap.pn==1, LES13_impact.pn, NA),
         LES14_impact.pn = ifelse(LES14_hap.pn==1, LES14_impact.pn, NA),
         LES15_impact.pn = ifelse(LES15_hap.pn==1, LES15_impact.pn, NA),
         
         LES16_impact.pn = ifelse(LES16_hap.pn==1, LES16_impact.pn, NA),
         LES17_impact.pn = ifelse(LES17_hap.pn==1, LES17_impact.pn, NA),  
         LES18_impact.pn = ifelse(LES18_hap.pn==1, LES18_impact.pn, NA),
         
         LES19_impact.pn = ifelse(LES19_hap.pn==1, LES19_impact.pn, NA),
         LES20_impact.pn = ifelse(LES20_hap.pn==1, LES20_impact.pn, NA),
         LES21_impact.pn = ifelse(LES21_hap.pn==1, LES21_impact.pn, NA),
         LES22_impact.pn = ifelse(LES22_hap.pn==1, LES22_impact.pn, NA))

Calculate summary scores

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R to treat columns as numeric
  mutate_at(vars(c(LES1_hap.pn:LES22_impact.pn)), as.numeric) %>%
  
  # Calculate total scores
  mutate(LES_tot.pn = sum(c_across(LES1_impact.pn:LES22_impact.pn), na.rm = T), 3) %>%
  mutate(LES_pos.pn = {
    x <- c_across(ends_with('impact.pn'))
    sum(x[x > 0], na.rm = T)
    }) %>%
  mutate(LES_neg.pn = {
    x <- c_across(ends_with('impact.pn'))
    sum(x[x < 0], na.rm = T)
    }) %>%
  
  # Recode 0 values as NA
  mutate(LES_tot.pn = na_if(LES_tot.pn, 0)) %>%
  mutate(LES_pos.pn = na_if(LES_pos.pn, 0)) %>% 
  mutate(LES_neg.pn = na_if(LES_neg.pn, 0)) %>%

  # Move the total score so they come immediately after the measures
  relocate(c(LES_pos.pn, LES_neg.pn, LES_tot.pn), .after = LES22_impact.pn)

MAAS/PAAS: Maternal/Paternal Antenatal Attachment Scale

Notes

Scoring Instructions

1993 Condon Factor Analysis
  • Two Subscales: Quality and Preoccupation MAAS
  • Quality: n = 11
  • Preoccupation: n = 8 PAAS
  • Quality: n = 10
  • Preoccupation: n = 6
Scale Means

SPSS Syntax Note

  • Syntax generates a maternal and paternal version of the scale

Qualtrics Scoring

  • Maternal Attachment: Q106-Q124 (19 questions total)
  • Paternal Attachment: Q90.1-Q105 (16 questions total)
  • Scoring goes from 1-5

Script

MAAS

Rename MAAS columns
# Get Column Numbers
cols <- which(colnames(df.pn)=="Q106.pn"):which(colnames(df.pn)=="Q124.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("MAAS", 1:19, ".pn", sep = ""))
Reverse score items
# Reverse Code Key
reverse_key <- setNames(c(1:5), 5:1)

# Reverse Score Q's 1, 3, 5, 6, 7, 9, 10, 12, 15, 16, 18
df.pn <- df.pn %>%
  mutate_at(vars(c(MAAS1.pn, MAAS3.pn, MAAS5.pn, 
                   MAAS6.pn, MAAS7.pn, MAAS9.pn, 
                   MAAS10.pn, MAAS12.pn, MAAS15.pn,
                   MAAS16.pn, MAAS18.pn)),
            ~recode(., !!!reverse_key))

# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("MAAS1.pn", "MAAS3.pn", "MAAS5.pn", 
                             "MAAS6.pn", "MAAS7.pn", "MAAS9.pn", 
                             "MAAS10.pn", "MAAS12.pn", "MAAS15.pn",
                             "MAAS16.pn", "MAAS18.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("MAAS1.pn", "MAAS3.pn", "MAAS5.pn", 
                             "MAAS6.pn", "MAAS7.pn", "MAAS9.pn", 
                             "MAAS10.pn", "MAAS12.pn", "MAAS15.pn",
                             "MAAS16.pn", "MAAS18.pn")))
Calculate summary scores
df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(MAAS1_r.pn:MAAS19.pn)), as.numeric) %>%
  
  # Calculate total scores/subscales
  mutate(MAAS_tot.pn = round(sum(c_across(MAAS1_r.pn:MAAS19.pn), na.rm = T), 3),
         MAAS_qual.pn = round(sum(c(MAAS19.pn, MAAS3_r.pn, MAAS11.pn,
                                    MAAS12_r.pn, MAAS15_r.pn, MAAS13.pn, 
                                    MAAS16_r.pn, MAAS9_r.pn, MAAS10_r.pn,
                                    MAAS6_r.pn, MAAS7_r.pn), na.rm = T), 3),
         MAAS_pre.pn = round(sum(c(MAAS1_r.pn, MAAS5_r.pn, MAAS8.pn, 
                                   MAAS4.pn, MAAS2.pn, MAAS17.pn, 
                                   MAAS18_r.pn, MAAS14.pn), na.rm = T), 3)) %>%
  
  # Move the total score/subscales so they come immediately after the measures
  relocate(c(MAAS_qual.pn, MAAS_pre.pn, MAAS_tot.pn), .after = MAAS19.pn)

Clean up summary scores

df.pn <- df.pn %>%
  mutate(across(c(MAAS_tot.pn:MAAS_pre.pn), ~na_if(., 0))) 

PAAS

Rename PAAS columns
# Get Column Numbers
cols <- which(colnames(df.pn)=="Q90.1.pn"):which(colnames(df.pn)=="Q105.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("PAAS", 1:16, ".pn", sep = ""))
Reverse score items
# Reverse Code Key
reverse_key <- setNames(c(1:5), 5:1)

# Reverse Score Q's 1, 3, 5, 6, 7, 8, 12, 13, 15
df.pn <- df.pn %>%
  mutate_at(vars(c(PAAS1.pn, PAAS3.pn, PAAS5.pn, 
                   PAAS6.pn, PAAS7.pn, PAAS8.pn, 
                   PAAS12.pn, PAAS13.pn, PAAS15.pn)),
            funs(recode(., !!!reverse_key)))

# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("PAAS1.pn", "PAAS3.pn", "PAAS5.pn", 
                             "PAAS6.pn", "PAAS7.pn", "PAAS8.pn", 
                             "PAAS12.pn", "PAAS13.pn", "PAAS15.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("PAAS1.pn", "PAAS3.pn", "PAAS5.pn", 
                             "PAAS6.pn", "PAAS7.pn", "PAAS8.pn", 
                             "PAAS12.pn", "PAAS13.pn", "PAAS15.pn")))
Calculate summary scores
df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(PAAS1_r.pn:PAAS16.pn)), as.numeric) %>%
  
  # Calculate total scores/subscales
  mutate(PAAS_tot.pn = round(sum(c_across(PAAS1_r.pn:PAAS16.pn), na.rm = T), 3),
         PAAS_qual.pn = round(sum(c(PAAS7_r.pn, PAAS3_r.pn, PAAS9.pn,
                                    PAAS12_r.pn, PAAS11.pn, PAAS2.pn,
                                    PAAS16.pn, PAAS1_r.pn, PAAS6_r.pn, 
                                    PAAS13_r.pn), na.rm = T), 3),
         PAAS_pre.pn = round(sum(c(PAAS10.pn, PAAS15_r.pn, PAAS14.pn,
                                   PAAS5_r.pn, PAAS4.pn, PAAS8_r.pn), 
                                 na.rm = T), 3)) %>%
  
  # Move the total score/subscales so they come immediately after the measures
  relocate(c(PAAS_qual.pn, PAAS_pre.pn, PAAS_tot.pn), .after = PAAS16.pn)

Clean up summary scores

df.pn <- df.pn %>%
  mutate(across(c(PAAS_tot.pn:PAAS_pre.pn), ~na_if(., 0))) 

MAT: Marital Adjustment Test

Notes

Scoring Instructions

SPSS Syntax Notes

  • The MAT variables are weird, so we are going to rename them
    • There are 15 items
      • Item 2 has sub-items 1:8 (should be turned into 2:9)
      • Item 12 has two parts
  • Fixed scoring for each item
  • Created a sum score where higher values mean greater satisfaction

Script

Rename MAT Columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="MAT_1.pn"):which(colnames(df.pn)=="MAT_15.pn")

# Replace Names in Data Set
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = 
           c(paste("MAT", 1:11, ".pn", sep = ""),
             "MAT12a.pn", "MAT12b.pn",
             paste("MAT", 13:15, ".pn", sep = "")))

Recode Scores by Item (references SPSS syntax)

df.pn <- df.pn %>%

  # Convert MAT Q1
  mutate_at(vars(c(MAT1.pn)), 
            funs(recode(., 
                        '1' = '0',
                        '2' = '2',
                        '3' = '7',
                        '4' = '15',
                        '5' = '20',
                        '6' = '25', 
                        '7' = '35'))) %>%
  # Convert MAT Q4
  mutate_at(vars(c(MAT4.pn)),
            funs(recode(., 
                        '1' = '8',
                        '2' = '6', 
                        '3' = '4',
                        '4' = '2',
                        '5' = '1',
                        '6' = '0'))) %>%
  # Convert MAT Q6
  mutate_at(vars(c(MAT6.pn)),
            funs(recode(., 
                        '1' = '15',
                        '2' = '12', 
                        '3' = '9',
                        '4' = '4',
                        '5' = '1',
                        '6' = '0'))) %>%
  # Convert MAT Q10
  mutate_at(vars(c(MAT10.pn)),
            funs(recode(., 
                        '1' = '0',
                        '2' = '2', 
                        '3' = '10'))) %>%
  # Convert MAT Q11
  mutate_at(vars(c(MAT11.pn)),
            funs(recode(., 
                        '1' = '10',
                        '2' = '8', 
                        '3' = '3',
                        '4' = '0'))) %>%
  # Convert MAT 13
  mutate_at(vars(c(MAT13.pn)),
            funs(recode(., 
                        '1' = '0',
                        '2' = '3', 
                        '3' = '8',
                        '4' = '15'))) %>%
  # Convert MAT 14
  mutate_at(vars(c(MAT14.pn)),
            funs(recode(., 
                        '1' = '15',
                        '2' = '0', 
                        '3' = '1'))) %>%
  # Convert MAT 15
  mutate_at(vars(c(MAT15.pn)),
            funs(recode(., 
                        '1' = '0',
                        '2' = '2', 
                        '3' = '10',
                        '4' = '10'))) %>%
  
  # Convert MAT Q's 2, 3, 5, 7, 8, 9
  mutate_at(vars(c(MAT2.pn, MAT3.pn, MAT5.pn,
                   MAT7.pn:MAT9.pn)),
            funs(recode(., 
                        '1' = '5',
                        '2' = '4', 
                        '3' = '3',
                        '4' = '2',
                        '5' = '1',
                        '6' = '0'))) %>%
  # Convert MAT 12
  mutate(MAT12.pn = ifelse(MAT12a.pn != MAT12b.pn, '2',
                               ifelse(MAT12a.pn == '1', '3', 
                                      ifelse(MAT12a.pn == '2', '10', NA)))) %>%
  relocate(MAT12.pn, .after = MAT12b.pn) %>%
  select(-c(MAT12a.pn, MAT12b.pn))

Calculate Sum Score

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that MAT scores are numeric
  mutate_at(vars(c(MAT1.pn:MAT15.pn)), as.numeric) %>%
  
  # Calculate total scores
  mutate(MAT_tot.pn = sum(c_across(MAT1.pn:MAT15.pn))) %>%
  
  # Move the summmary scores so they come immediately after the measures
  relocate(MAT_tot.pn, .after = MAT15.pn) 

MOS: Medical Outcomes Study Social Support Survey

Notes

General Notes

  • Sherborne & Stewart, 1993
Mean Values of Subscales

SPSS Syntax Notes

  • This syntax generates four subscales (emotional support, tangible support, affective support, and positive social interaction) and a total score.

Qualtrics Scoring

Script

Rename MOS columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="MOS_1.pn"):which(colnames(df.pn)=="MOS_19.pn")

# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Calculate summary scores

df.pn <- df.pn %>%
  
  # First, make sure R knows to treat DAS values as numbers
  mutate_at(vars(c(MOS1.pn:MOS19.pn)), as.numeric) %>% 
  
  # Then tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Calculate the summary scores for moms
  mutate(MOS_emo.pn = round(mean(c_across(MOS1.pn:MOS8.pn), na.rm = T), 2),
         MOSt_ang.pn = round(mean(c_across(MOS9.pn:MOS12.pn), na.rm = T),2),
         MOS_aff.pn = round(mean(c_across(MOS13.pn:MOS15.pn), na.rm = T),2),
         MOS_soc.pn = round(mean(c_across(MOS16.pn:MOS18.pn), na.rm = T),2),
         MOS_tot.pn = round(mean(c_across(MOS1.pn:MOS19.pn), na.rm = T),2)) %>%
  
  # Finally, move the summary scores so that they come immediately after the measures
  relocate(c(MOS_emo.pn:MOS_tot.pn), .after = MOS19.pn) 

Convert NaN to NA

df.pn <- df.pn %>%
  mutate(across(c(MOS_emo.pn:MOS_tot.pn), ~na_if(., "NaN"))) 

PAS: Pregnancy Anxiety Scale

Notes

General Notes

  • Dunkel-Schetter et. al
  • Use only the 10-item version (drop questions 2, 9, and 10)

Scoring Instructions

SPSS Syntax Notes

  • We’ll score the PAS using the newer version without the ‘gaining weight’ (10), ‘paying bills’ (9), and ‘feeling informed’ (2) items that have not been used in more recent studies, per Christine Guardino.
    • The older version includes all items
  • Reverse score 1, 2, and 3
  • Rename questions
Question Renaming Syntax from SPSS

Qualtrics Scoring

PAS Questions 1-6

PAS Questions 7-13

Script

Rename PAS Columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="Q72_1.pn"):which(colnames(df.pn)=="Q73_7.pn")

# Set New Names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("PAS", 1:13, ".pn", sep = ""))

Recode PAS Values According to Author Scoring Instructions

df.pn <- df.pn %>%
  # Reverse Code Items 1-3
  mutate_at(vars(c(PAS1.pn:PAS3.pn)), 
            funs(recode(., 
                        '1' = '4',
                        '2' = '3',
                        '4' = '2',
                        '5' = '1'))) %>%
  # Recode Items 4-6
  mutate_at(vars(c(PAS4.pn:PAS6.pn)), 
            funs(recode(., 
                        '1' = '1',
                        '2' = '2',
                        '4' = '3',
                        '5' = '4'))) %>%
  # Recode Items 7-13
  mutate_at(vars(c(PAS7.pn:PAS13.pn)), 
            funs(recode(., 
                        '1' = '1',
                        '2' = '2',
                        '6' = '3',
                        '7' = '4')))

Rename Reverse-Coded PAS Items 1, 2, 3

# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("PAS1.pn", "PAS2.pn", "PAS3.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("PAS1.pn", "PAS2.pn", "PAS3.pn")))

Calculate Mean Score

df.pn <- df.pn %>% 
  # First, make sure R knows to treat PSAM values as numbers
  mutate_at(vars(c(PAS1_r.pn:PAS13.pn)), as.numeric)%>% 
  
  # Then tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Now take the mean of the 10 items included in the newer version of the measure
  mutate(PAS_mean.pn = mean(c(PAS1_r.pn, PAS3_r.pn, c_across(PAS4.pn:PAS8.pn), c_across(PAS11.pn:PAS13.pn)), na.rm = T)) %>% 

  # Finally, move the mean scores so that they come immediately after the measures
  relocate(PAS_mean.pn, .after = PAS13.pn) 

Clean up NAs

# When we took the mean, it introduced NaN, which R views as text rather than as a true NA
df.pn$PAS_mean.pn[df.pn$PAS_mean.pn == "NaN"] <- NA

Pregnancy/Couvade Syndrome Symptoms

Notes

General Notes

  • Brennan
  • Item and Reliability Information
  • Original questionnaire has 31 questions on physical symptoms and 19 questions on psychological symptoms (50 total)
  • Physical symptoms fells into 6 areas:
    • Gastrointestinal
    • Respiratory
    • Genitio-urinary
    • Oral-dental
    • Muscoloskeletal
    • Misc.
  • Psychological symptoms fell into 4 categories:
    • Sleep problems
    • Mood disturbances
    • Emotional affect
    • Motivation
    • Cognitive problems
    • Coping ability

Scoring Instructions

  • There are 44 symptoms, indicated by number
  • There are 4 questions per symptoms
    • Question 1: Presence/Absence
      • 1 = Yes, 2 = No
    • Question 2: Severity
      • 1 = No at all severe; 9 = the most severe
    • Question 3: Distressing-ness
      • Not at all distressing; 9 = the most distressing
    • Question 4: Frequency
      • we removed this measure

SPSS Syntax Note

  • This generates subscales for the number of pregnancy symptoms, their severity, distressing-ness, and frequency, and a total sum score of all the subscales.

Script

Rename PregSymp Columns

Presence/ Absence
# Get Column Numbers
cols <- which(colnames(df.pn)=="PregSymp.1_1.pn"):which(colnames(df.pn)=="PregSymp.1_44.pn")

# Set New Names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("PregSymp", 1:44, "_presence.pn", sep = ""))
Severity
# Get Column Numbers
cols <- which(colnames(df.pn)=="PregSymp.2_1.pn"):which(colnames(df.pn)=="PregSymp.2_44.pn")

# Set New Names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("PregSymp", 1:44, "_severe.pn", sep = ""))
Distressing-ness
# Get Column Numbers
cols <- which(colnames(df.pn)=="PregSymp.3_1.pn"):which(colnames(df.pn)=="PregSymp.3_44.pn")

# Replace ".3" in column names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("PregSymp", 1:44, "_distress.pn", sep = ""))
Frequency (removed from dataset)
df.pn <- select(df.pn, -c(starts_with("PregSymp.4")))

Recode Pregnancy Symptom Presence to 1/0 dummy

df.pn <- df.pn %>%
  mutate_at(vars(c(PregSymp1_presence.pn:PregSymp44_presence.pn)), 
            funs(recode(., 
                        '1' = '1',
                        '2' = '0',
                        )))

Calculate Summary Scores

df.pn <- df.pn %>%
  mutate_at(vars(c(PregSymp1_presence.pn:PregSymp44_distress.pn)), as.numeric) %>%
  
  rowwise() %>%
  
  # Presence
  mutate(PregSymp_total.pn = sum(c_across(PregSymp1_presence.pn:PregSymp44_presence.pn), na.rm = T)) %>%
  
  # Severity
  mutate(PregSymp_tot_severe.pn = mean(c_across(PregSymp1_severe.pn:PregSymp44_severe.pn), na.rm = T)) %>%
  
  # Distress
  mutate(PregSymp_tot_distress.pn = mean(c_across(PregSymp1_distress.pn:PregSymp44_distress.pn), na.rm = T)) %>%
  
  # Finally, move the summary scores so that they come immediately after the measure
  relocate(c(PregSymp_total.pn, PregSymp_tot_severe.pn, PregSymp_tot_distress.pn),
           .after = PregSymp44_distress.pn)

Clean up summary scores

df.pn$PregSymp_total.pn[df.pn$CoupleID == 37 | df.pn$CoupleID == 73] <- NA

# Change NA variables
df.pn$PregSymp_tot_severe.pn[df.pn$PregSymp_tot_severe.pn == "NaN"] <- NA
df.pn$PregSymp_tot_distress.pn[df.pn$PregSymp_tot_distress.pn == "NaN"] <- NA

PSAM: Pregnancy Specific Anxiety Measure

Notes

General Notes

  • Dunkel-Schetter et. al
  • In Qualtrics, PSAM and PAS are clumped together. Questions 1-13 are PSAM, and the remaining questions are PAS, which can be found in the following section.

Scoring Instructions

  • Author’s scoring instructions
  • Only 4 items are scored together to create a summary score, but they are embedded in a list of 13 total adjectives
    • anxious (1), concerned (5), afraid (9), and panicky (11)

SPSS Syntax

  • SPSS: for the most recent version of the survey (1.26.2018 and beyond), you can skip the renaming step, so that syntax is greyed out.

Qualtrics Scoring

Script

Rename PSAM Columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="PSAM_1.pn"):which(colnames(df.pn)=="PSAM_13.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Calculate Mean Scores

df.pn <- df.pn %>% 
  # First, make sure R knows to treat PSAM values as numbers
  mutate_at(vars(c(PSAM1.pn:PSAM13.pn)), as.numeric) %>%
  
  # Then tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Now take the mean of the four embedded items 
  mutate(PSAM_mean.pn = mean(c(PSAM1.pn, PSAM5.pn, PSAM9.pn, PSAM11.pn), na.rm = T)) %>%
  
  # Finally, move the mean scores so that they come immediately after the measures
  relocate(PSAM_mean.pn, .after = PSAM13.pn) 

Clean up NAs

# When we took the mean, it introduced NaN, which R views as text rather than as a true NA
df.pn$PSAM_mean.pn[df.pn$PSAM_mean.pn == "NaN"] <- NA

PSQI: Pittsburgh Sleep Quality Index

Notes

General Notes

  • Buysee et al., 1989
  • Questions 1-4 allowed parents to enter text, so we had to go in to clean up the text by hand
    • Question 1: if they listed a range of times, we selected the first time offered
    • Question 2: if they listed a range of times, we took the average
    • Question 3: if they listed a range of times, we selected the first time offered
      • I also converted to AM if it seemed appropriate given sleep time (even if they listed a PM time for wakeup b/c it seemed like a mistake)
      • For dad #34, he reported going to sleep at 7 AM and waking up at 1 PM
    • Question 4: if they listed a range of times, we took the average
      • Dads #67 and #69 have strange answers (128 and 180 hours), so they were recoded as NA
  • Component 5: I replaced missing values in 5b-5j with the mean of 5b-5j and then took the sum before recoding
  • For global PSQI, a score over 5 indicates poor sleep quality. In our sample, 45 mothers and 40 dads have poor sleep quality PRENATALLY
    • Check to make sure that’s correct!

Scoring Instructions

SPSS Syntax Notes

  • The PSQI is comprised of seven components (sleep quality, latency, duration, efficiency, disturbances, use of sleep medication, and daytime dysfuction)
  • This syntax does not include a sleep efficiency score so we are scoring based on the total of six rather than seven components.
  • We can calculate sleep efficiency but it will require some manual data editing because the sleep and wake times are currently entered as string variables.
  • A number of studies have used the PSQI minus the “efficiency” component but be mindful that our means/ranges may differ from studies that use the full PSQI.
  • IMPORTANT! PSQI_2 & PSQI_4 are string variables that you will have to manually edit to be numerical
    • e.g., edit “15 minutes” to be “15” and “7 hours 30 minutes” to be 7.5

Qualtrics Scoring

  • In the Qualtrics survey, there are two Q98and two Q96
    • Q98.1.pn.dad appears to be the Paternal Attachment Scale, while Q98.pn.mom and Q98.pn.dad are part of the PSQI
    • Q96.pn.dad appears to be the Paternal Attachment Scale, whileQ96_1 and Q96_2 are part of the PSQI
Question 5

Question 5 has sub-questions a-j

Questions 6-7

Scoring for 7 is the same as for 6 (which is listed below)

Question 8

Question 9

Script

Set up

Reorder columns so all PSQI columns are in order
df.pn <- df.pn %>% 
  relocate(c(Q94.pn), .after = Q98.pn)
Rename PSQI columns
# Mom questions 1-4
# Get Column Numbers
cols <- which(colnames(df.pn)=="Q84.pn"):which(colnames(df.pn)=="Q90.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("PSQI", 1:4,".pn", sep = ""))

# Mom question 5
## Get Column Numbers
cols <- which(colnames(df.pn)=="Q92_1.pn"):which(colnames(df.pn)=="Q92_10.pn")
## Set names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("PSQI", "5", letters[1:10], ".pn", sep = ""))

# Mom questions 6-9
# Get Column Numbers
cols <- which(colnames(df.pn)=="Q96_1.pn"):which(colnames(df.pn)=="Q94.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("PSQI", 6:9, ".pn", sep = ""))

Recode item responses

Item 1
df.pn <- df.pn %>% 

  ungroup() %>%
  
  # Upper-to-lower case and delete spaces
  mutate(PSQI1.pn = tolower(PSQI1.pn)) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, " ", "")) %>%
  
  # Remove common words/punctuation
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "between", "")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "around", "")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "at", "")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "-", ":00")) %>%

  
  # Specific Cases
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "iusuallygotobed9", "9:00")) %>%
  mutate(PSQI1.pn = na_if(PSQI1.pn, "yes,always")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "aspecifictime[(]9pm[)]", "21:00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "inthemorning", "am")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "and2o'clock", "am")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "23p", "23:00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "p[.]m[.]", ":00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "or", ":00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "to", "pm")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "10[.]30pm", "10:30")) %>%

  # Convert to military
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "midnight", "00:00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "12am", "00:00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "12:001am", "00:00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "12:30am", "00:30")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "1am", "01:00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "2am", "02:00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "3am", "03:00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "7am", "07:00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "8", "20")) %>% 
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "9", "21")) %>% 
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "10", "22")) %>% 
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "11", "23")) %>% 
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "eleven", "23")) %>% 
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "pm", ":00")) %>%  
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "p", ":00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "am", ":00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "a", ":00")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "0:00", "00:00")) %>%
   
  # Reduce to 5 digits
  mutate(PSQI1.pn = str_sub(PSQI1.pn, start = 1, end = 5)) %>%
  
  # Add missing minutes
  mutate(PSQI1.pn = ifelse(str_length(PSQI1.pn)==2, str_c(PSQI1.pn, ":00"), PSQI1.pn)) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "2230", "22:30")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "22.30", "22:30")) %>%
  mutate(PSQI1.pn = str_replace_all(PSQI1.pn, "000:0", "00:00")) %>%
  
  # Add missing seconds
  mutate(PSQI1.pn = str_c(PSQI1.pn, ":00"), PSQI1.pn) %>%
  
  # Convert to time format
  mutate(PSQI1.pn = times(PSQI1.pn))
Item 2
df.pn <- df.pn %>% 
  
  rowwise() %>%
  
  # Upper-to-lower case and delete spaces/punctuation
  mutate(PSQI2.pn = tolower(PSQI2.pn)) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, " ", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "[.]", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "[/]", "-")) %>%
  
  # Common Words/phrases
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "lessthan", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "minute", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "minutes", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "mins", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "min", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "1hour", "60")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "onehour", "60")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "anhour", "60")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "about", "")) %>%
  
  # Specific Cases
  mutate(PSQI2.pn = na_if(PSQI2.pn, "imnotsure")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "immediately", "1")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "orless", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "lessthan", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "immediately", "1")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "between0sto60sdependingifi'vewokenupinthemiddleofthenight", "30")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "typicallyasfastas5[-]10ometimesasslowas45[(]ilistentohypnobabiesandtypicallyfallasleepbeforethe30tapeends", "25")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "twentytothirty", "25")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "1-2hour", "90")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "max", "")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "to", "-")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "ten", "10")) %>%
  mutate(PSQI2.pn = str_replace_all(PSQI2.pn, "s", "")) %>%
  
  # Take average of a range
  mutate(PSQI2.pn = str_split(string = PSQI2.pn, pattern = "-")) %>%
  mutate(PSQI2.pn = mean(as.numeric(PSQI2.pn)))
Item 3
df.pn <- df.pn %>% 
  
  ungroup() %>%
  
  # Upper-to-lower case and delete spaces
  mutate(PSQI3.pn = tolower(PSQI3.pn)) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, " ", "")) %>%
  
  # Remove common words/punctuation
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "between", "")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "around", "")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "about", "")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "a.m.", "am")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "-", "am")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "[.]", ":")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "[;]", ":")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "[,]", "")) %>%
  
  # Specific Cases
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "igetup5inthemorning", "5:00")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "630amweekdays8am9amweekends", "6:30")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "onworkdaysigetup6:30amweekendsisleepinalittlemoreandusuallygetup7am8am:", "6:30")) %>%
  mutate(PSQI3.pn = na_if(PSQI3.pn, "multipletimestousetherestroomprobably3timesbeforemyalarmgoesoff")) %>%
  mutate(PSQI3.pn = na_if(PSQI3.pn, "5pm")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "530", "5:30")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "545", "5:45")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "615", "6:15")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "630", "6:30")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "sevenfifteenam", "7:15")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "eightthirtyam", "8:30")) %>%
  mutate(PSQI3.pn = na_if(PSQI3.pn, "aftersnoozingmyalamnce")) %>%
  
  # Convert to military
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "pm", ":00")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "am", ":00")) %>%
  mutate(PSQI3.pn = str_replace_all(PSQI3.pn, "a", ":00")) %>%
  
  # Increase/Reduce to 4 digits
  mutate(PSQI3.pn = ifelse(PSQI3.pn == "4", "4:00", PSQI3.pn)) %>%
  mutate(PSQI3.pn = ifelse(PSQI3.pn == "5", "5:00", PSQI3.pn)) %>%
  mutate(PSQI3.pn = ifelse(PSQI3.pn == "6", "6:00", PSQI3.pn)) %>%
  mutate(PSQI3.pn = ifelse(PSQI3.pn == "7", "7:00", PSQI3.pn)) %>%
  mutate(PSQI3.pn = ifelse(PSQI3.pn == "8", "8:00", PSQI3.pn)) %>%
  mutate(PSQI3.pn = str_sub(PSQI3.pn, start = 1, end = 4)) %>%
  
  # Add missing digits
  mutate(PSQI3.pn = str_c("0", PSQI3.pn, ":00")) %>%
  
  # Fix parents who wake up at 11 AM and 1 PM 
  mutate(PSQI3.pn = ifelse(PSQI3.pn=="011:0:00", "11:00:00", PSQI3.pn)) %>%
  mutate(PSQI3.pn = ifelse(PSQI3.pn=="01:00:00", "13:00:00", PSQI3.pn)) %>%

  # Convert to time format
  mutate(PSQI3.pn = ifelse(CoupleID == 33 & Parent == "mom", NA, PSQI3.pn)) %>%
  mutate(PSQI3.pn = times(PSQI3.pn))
Item 4
df.pn <- df.pn %>% 
  
  rowwise() %>%
  
  # Upper-to-lower case and delete spaces/punctuation
  mutate(PSQI4.pn = tolower(PSQI4.pn)) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, " ", "")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "[,]", "")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "[']", "")) %>%
  
  # Common Words/phrases
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "hours", "")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "hrs", "")) %>%
  
  # Specific Cases
  mutate(PSQI4.pn = na_if(PSQI4.pn, "idontknowbecauseiamupacoupletimestogotothebathroomandiamconstantlytossingandturningtofindacomfortableposition")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "nottosuremaybearound6", "6")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "6.5[(]weekdays[)]moreonweekendsmaybe8.5weekends", "7.5")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "aday", "")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "anight", "")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "night", "")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "to", "-")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "[/]", "")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "per", "")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "andahalf", ".5")) %>%
  mutate(PSQI4.pn = str_replace_all(PSQI4.pn, "eight", "8")) %>%


  # Take average of a range
  mutate(PSQI4.pn = str_split(string = PSQI4.pn, pattern = "-")) %>%
  mutate(PSQI4.pn = mean(as.numeric(PSQI4.pn))) %>%
  
  # Remove excessive outliers
  mutate(PSQI4.pn = na_if(PSQI4.pn, 128)) %>%
  mutate(PSQI4.pn = na_if(PSQI4.pn, 180))
Items 5-9
df.pn <- df.pn %>%
  mutate_at(vars(c(PSQI5a.pn:PSQI9.pn)), 
            funs(recode(., 
                        '1' = '0',
                        '2' = '1',
                        '3' = '2',
                        '4' = '3'))) %>%
  mutate_at(vars(c(PSQI5a.pn:PSQI9.pn)), as.numeric)

Calculate component scores

Component 1
df.pn <- df.pn %>%
  mutate(PSQI_c1.pn = PSQI9.pn)
Component 2
df.pn <- df.pn %>%
  
  rowwise() %>%
  
  # Recode Question 2
  mutate(PSQI_c2.pn = ifelse(PSQI2.pn <= 15, 0, 
                                ifelse(PSQI2.pn >= 16 & PSQI2.pn <= 30, 1, 
                                       ifelse(PSQI2.pn >= 31 & PSQI2.pn <= 60, 2, 
                                              ifelse(PSQI2.pn > 60, 3, NA))))) %>%
  
  # Sum Questions 2 and 5a
  mutate(PSQI_c2.pn = PSQI_c2.pn+PSQI5a.pn) %>%
  
  # Recode Component 2
  mutate(PSQI_c2.pn = ifelse(PSQI_c2.pn == 0, 0,
                                ifelse(PSQI_c2.pn == 1 | PSQI_c2.pn == 2, 1,
                                       ifelse(PSQI_c2.pn == 3 | PSQI_c2.pn == 4, 2, 
                                              ifelse(PSQI_c2.pn==5 | PSQI_c2.pn == 6, 3, NA)))))
Component 3
df.pn <- df.pn %>%
  
  rowwise() %>%
  
  mutate(PSQI_c3.pn = ifelse(PSQI4.pn > 7, 0,
                                ifelse(PSQI4.pn <= 7 & PSQI4.pn > 6, 1, 
                                       ifelse(PSQI4.pn <= 6 & PSQI4.pn > 5, 2,
                                              ifelse(PSQI4.pn <= 5, 3, NA))))) 
Component 4
df.pn <- df.pn %>%
  
  rowwise() %>%
  
  # Add fake date so that R knows that parents are waking up the day after they go to bed 
        # I just chose a random date (happened to be the date I was working)
  mutate(PSQIam.pn = as.POSIXct(chron(dates. = "06/27/2022", times. = PSQI3.pn))+25200) %>% 
  mutate(PSQIpm.pn = as.POSIXct(chron(dates. = "06/26/2022", times. = PSQI1.pn))+25200) %>%
  
  # Tell R that parents who go to bed after midnight are actually sleeping the following day
  mutate(PSQIpm.pn = as.POSIXct(ifelse(PSQIpm.pn <= "2022-06-26 03:00:00", 
                                 PSQIpm.pn+86400, 
                                 PSQIpm.pn
                                 ), origin = "1970-01-01")) %>%
  
  
  # Find hours in bed
  mutate(PSQIhib.pn = as.numeric(difftime(PSQIam.pn, PSQIpm.pn, units = "hours"))) %>%
  
  # Calculate Component 4
  mutate(PSQI_c4.pn = (PSQI4.pn/PSQIhib.pn)*100) %>%
  
  # Recode Component 4
  mutate(PSQI_c4.pn = ifelse(PSQI_c4.pn >= 85, 0,
                                 ifelse(PSQI_c4.pn < 85 & PSQI_c4.pn >= 75, 1, 
                                        ifelse(PSQI_c4.pn < 75 & PSQI_c4.pn >= 65, 2, 
                                               ifelse(PSQI_c4.pn < 64, 3, NA))))) %>%
  
  # Remove helper variables
  select(-c(PSQIam.pn, PSQIpm.pn, PSQIhib.pn))
Component 5
df.pn <- df.pn %>%
  
  rowwise() %>%
  
  # Calculate mean
  mutate(PSQI5mean.pn = mean(c_across(PSQI5b.pn:PSQI5j.pn), na.rm = T)) %>%
  mutate(PSQI5mean.pn = ifelse(PSQI5mean.pn == "NaN", NA, PSQI5mean.pn)) %>%
  
  # Replace missing values with mean
  mutate(PSQI5h.pn2 = tidyr::replace_na(PSQI5h.pn, PSQI5mean.pn)) %>%
  mutate(PSQI5j.pn2 = tidyr::replace_na(PSQI5j.pn, PSQI5mean.pn)) %>%
  
  # Calculate Component 5
  mutate(PSQI_c5.pn = sum(c(c_across(PSQI5b.pn:PSQI5g.pn), PSQI5h.pn2, PSQI5i.pn, PSQI5j.pn2))) %>%
  
  # Recode Component 5
  mutate(PSQI_c5.pn = ifelse(PSQI_c5.pn == 0, 0,
                                 ifelse(PSQI_c5.pn >= 1 & PSQI_c5.pn <= 9, 1, 
                                        ifelse(PSQI_c5.pn >= 10 & PSQI_c5.pn <= 18, 2, 
                                               ifelse(PSQI_c5.pn >= 19, 3, NA))))) %>%
  
  # Remove helper variables
  select(-c(PSQI5mean.pn, PSQI5h.pn2, PSQI5j.pn2))
Component 6
df.pn <- df.pn %>%
  mutate(PSQI_c6.pn = PSQI6.pn) 
Component 7
df.pn <- df.pn %>%
  
  rowwise() %>%
  
  # Moms
  mutate(PSQI_c7.pn = sum(c(PSQI7.pn, PSQI8.pn))) %>%
  mutate(PSQI_c7.pn = ifelse(PSQI_c7.pn == 0, 0, 
                                 ifelse(PSQI_c7.pn == 1 | PSQI_c7.pn == 2, 1, 
                                        ifelse(PSQI_c7.pn == 3 | PSQI_c7.pn == 4, 2, 
                                               ifelse(PSQI_c7.pn == 5 | PSQI_c7.pn == 6, 3, 
                                                      NA)))))
Tidy
df.pn <- df.pn %>%
  
  relocate(c(PSQI_c1.pn, PSQI_c2.pn, PSQI_c3.pn, PSQI_c4.pn, PSQI_c5.pn, PSQI_c6.pn, PSQI_c7.pn), 
             .after = PSQI9.pn) 

Total PSQI

df.pn <- df.pn %>%
  
  rowwise() %>%
  
  # Calculate total score
  mutate(PSQI_tot.pn = sum(c_across(PSQI_c1.pn:PSQI_c7.pn))) %>%
  
  # Relocate variables
  relocate(PSQI_tot.pn, .after = PSQI_c7.pn) 

PSS: Perceived Stress Scale

Notes

General Notes

  • Cohen 1994
Score Ranges

Scoring Instructions

SPSS Syntax Note

  • Reverse code 4, 5, 6, 7, 9, 10, 13

Qualtrics Scoring

Script

Rename PSS columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="PSS_1.pn"):which(colnames(df.pn)=="PSS_14.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Recode item scores

df.pn <- df.pn %>%
# Re-code items
  mutate_at(vars(c(PSS1.pn:PSS14.pn)), 
            funs(recode(., 
                        '1' = '0',
                        '2' = '1',
                        '3' = '2',
                        '4' = '3', 
                        '5' = '4')))

Reverse score

# Reverse Code Key
reverse_key <- setNames(c(0:4), 4:0)

# Reverse Score Q's 4, 5, 6, 7, 9, 10, 13
df.pn <- df.pn %>%
  mutate_at(vars(c(PSS4.pn, PSS5.pn, PSS6.pn, 
                   PSS7.pn, PSS9.pn, PSS10.pn, 
                   PSS13.pn)),
            funs(recode(., !!!reverse_key)))

# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("PSS4.pn", "PSS5.pn", "PSS6.pn", 
                             "PSS7.pn", "PSS9.pn", "PSS10.pn", 
                             "PSS13.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("PSS4.pn", "PSS5.pn", "PSS6.pn", 
                             "PSS7.pn", "PSS9.pn", "PSS10.pn", 
                             "PSS13.pn")))

Calculate summary scores

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(PSS1.pn:PSS14.pn)), as.numeric) %>%
  
  # Calculate total scores/subscales
  mutate(PSS_tot.pn = sum(c_across(PSS1.pn:PSS14.pn), na.rm = T)) %>%
  
  # Clean up NAs
  mutate(across(PSS_tot.pn, ~na_if(., 0))) %>%
  
  # Move the total score/subscales so they come immediately after the measures
  relocate(PSS_tot.pn, .after = PSS14.pn)

RF: Risky Families

Notes

SPSS Syntax Notes

  • Reverse code certain items (1, 3, 6) so that higher scores = more risky families
  • Sum scores – higher scores will mean a riskier family

Script

Rename RF Columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="RF_1.pn"):which(colnames(df.pn)=="RF_11.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Reverse Score RF Items 1, 3, 6

# Reverse Code Key
reverse_key <- setNames(c(1:5), 5:1)

# Reverse Score Q's 1, 3, 6
df.pn <- df.pn %>%
  mutate_at(vars(c(RF1.pn, RF3.pn, RF6.pn)),
            funs(recode(., !!!reverse_key)))

# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("RF1.pn", "RF3.pn", "RF6.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("RF1.pn", "RF3.pn", "RF6.pn")))

Calculate Sum Score

df.pn <- df.pn %>% 
  mutate_at(vars(c(RF1_r.pn:RF11.pn)), as.numeric) %>%
  rowwise() %>%
  mutate(RF_tot.pn = sum(c_across(RF1_r.pn:RF11.pn))) %>%
  relocate(RF_tot.pn, .after = RF11.pn)

SCL: Symptom Checklist—90

Notes

General Notes

  • Derogatis et al., 1973
  • we only include 87 items
    • 2 items related to suicide were omitted
      • “Thoughts of ending your life” (#15) - depression subscale
      • “Thoughts of death or dying” (#59) - additional items
    • 1 item related to physical aggression was omitted
      • “Having urges to beat, injure, or harm someone.” (#63) - anger-hostility subscale

Scoring Instructions

  • Scoring Instructions are taken from SCL manual in QGlobal resource section (available to grad students conducting assessments at the PSC)
  • Item Order
  • 9 symptom dimensions
    • Somatization
    • Obsessive-Compulsive
    • Interpersonal Sensitivity
    • Depression
    • Anxiety
    • Hostility
    • Phobic Anxiety
    • Paranoid Ideation
    • Psychoticism
  • “Additional Items” category
  • Three global scores (Derogatis & Unger, 2010)
    • Global Severity Index
    • Positive Symptom Distress Index
    • Positive Symptom Total
Manual Scoring Manual

Subscales

Global Scales

Scale Means

SPSS Syntax Notes

  • note that SCL-DEP subscale has been calculated as a SUM rather than a MEAN score in the past
    • syntax is rewritten to MEAN to match the other subscales
    • but if you are scoring variables to merge into existing data, you can edit this to be a SUM score.
  • Darby seemed to exclude question 87?
  • Subscales computed using mean:
    1. SOM
    2. OC
    3. INT
    4. DEP
    5. ANX
    6. HOS
    7. PHOB
    8. PAR
    9. PSY
    10. ADDIT
  • GSI = general severity index = mean of 10 subscales
  • PSDI = positive items = count of something?
  • PST = positive symptoms total = GSI/ PSDI

Qualtrics Scoring

  • Our qualtrics items go in order, but skip over the omitted items such that subsequent items get mis-numbered

Script

Rename SCL columns

  • Have to account for the fact that questions 15, 59, and 63 were removed
# Get Column Numbers
cols <- which(colnames(df.pn)=="SCL90_1.pn"):which(colnames(df.pn)=="SCL90_87.pn")
# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = paste("SCL", c(1:14, # rename 1-14; remove 15
                              16:58, # rename 16-58; remove 59
                              60:62, # rename 60-62; remove 63
                              64:90), # rename 64-90
                     ".pn", sep = ""))

Recode item scores

df.pn <- df.pn %>%
# Re-code items
  mutate_at(vars(c(SCL1.pn:SCL90.pn)), 
            funs(recode(., 
                        '1' = '0',
                        '2' = '1',
                        '3' = '2',
                        '4' = '3',
                        '5' = '4')))

Calculate subscales

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that scores are numeric
  mutate_at(vars(c(SCL1.pn:SCL90.pn)), as.numeric) %>%
  
  # Calculate subscales
  mutate(SCL_som.pn = mean(c(SCL1.pn, SCL4.pn, SCL12.pn, 
                             SCL27.pn, SCL40.pn, SCL42.pn, 
                             SCL48.pn, SCL49.pn, SCL50.pn, 
                             SCL53.pn, SCL56.pn, SCL58.pn), 
                           na.rm = T) + .005, #12
         SCL_oc.pn = mean(c(SCL3.pn, SCL9.pn, SCL10.pn, 
                            SCL28.pn, SCL38.pn, SCL45.pn, 
                            SCL46.pn, SCL51.pn, SCL55.pn, SCL65.pn), 
                          na.rm = T) + .005, #10
         SCL_is.pn = mean(c(SCL6.pn, SCL21.pn, SCL34.pn,
                            SCL36.pn, SCL37.pn, SCL41.pn, 
                            SCL61.pn, SCL69.pn, SCL73.pn), 
                          na.rm = T) + .005, #9
         SCL_dep.pn = mean(c(SCL5.pn, SCL14.pn, SCL20.pn, 
                             SCL22.pn, SCL26.pn, SCL29.pn, 
                             SCL30.pn, SCL31.pn, SCL32.pn, 
                             SCL54.pn, SCL71.pn, SCL79.pn), 
                           na.rm = T) + .005, #13-1
         SCL_anx.pn = mean(c(SCL2.pn, SCL17.pn, SCL23.pn, 
                             SCL33.pn, SCL39.pn, SCL57.pn, 
                             SCL72.pn, SCL78.pn, SCL80.pn, SCL86.pn), 
                           na.rm = T) + .005, #the screenshot doesn't include 2, but 2 is included on the anxiety scale in the manual
         SCL_hos.pn = mean(c(SCL11.pn, SCL24.pn, SCL67.pn,
                              SCL74.pn, SCL81.pn), 
                            na.rm = T) + .005, #6-1
         SCL_phob.pn = mean(c(SCL13.pn, SCL25.pn, SCL47.pn, 
                              SCL50.pn, SCL70.pn, SCL75.pn, SCL82.pn), 
                            na.rm = T) + .005, #7
         SCL_par.pn = mean(c(SCL8.pn, SCL18.pn, SCL43.pn, 
                             SCL68.pn, SCL76.pn, SCL83.pn), 
                           na.rm = T) + .005, #6
         SCL_psy.pn = mean(c(SCL7.pn, SCL16.pn, SCL35.pn, 
                             SCL62.pn, SCL77.pn, SCL84.pn, 
                             SCL85.pn, SCL87.pn, SCL88.pn, SCL90.pn), 
                           na.rm = T) + .005, #10
         SCL_add.pn = mean(c(SCL19.pn, SCL44.pn,SCL60.pn, 
                             SCL64.pn, SCL66.pn, SCL89.pn), 
                           na.rm = T) + .005 #7-1
         ) %>%
  
  # Round to two decimals
  mutate(across(c(SCL_som.pn:SCL_add.pn), round, 2)) %>%
  
  # Replace NaN with NAs
  mutate(across(c(SCL_som.pn:SCL_add.pn), ~na_if(., "NaN")))

Calculate Global Scales

Calculate Global Severity Index
df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Count number of NAs in a row
  row_count(SCL1.pn:SCL90.pn, count = NA, var = "SCL_count_NA", append = T) %>%
  
  # Calculate total number of responses in a row
  mutate(SCL_totr = 87 - SCL_count_NA) %>%

  # Calculate Global Severity Index by dividing the sum of all responses by the total number of responses and adding .005
  mutate(SCL_gsi.pn = sum(c_across(SCL1.pn:SCL90.pn), na.rm = T)/SCL_totr + .005) %>%
  
  # Round to two decimals
  mutate(SCL_gsi.pn = round(SCL_gsi.pn, 2))
Calculate Positive Symptom Total
df.pn <- df.pn %>%
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Count number of zero-scored items in a row
  row_count(SCL1.pn:SCL90.pn, count = 0, var = "SCL_count_0", append = T) %>%

  # Calculate the Positive Symptom Total by subtracting the number of zero-value responses from the total number of responses
  mutate(SCL_pst.pn = SCL_totr - SCL_count_0)
Calculate Positive Symptoms Distress Index
df.pn <- df.pn %>%
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Calculate the Positive Symptoms Distress Index by dividing the sum of all responses by the PST  and adding .005
  mutate(SCL_psdi.pn = sum(c_across(SCL1.pn:SCL90.pn), na.rm = T)/SCL_pst.pn + .005) %>%
  
  # Round to two decimals
  mutate(SCL_psdi.pn = round(SCL_psdi.pn, 2))

Clean Up Subscales and Global Scores

 df.pn <- df.pn %>%
  
  # Remove helper variables
  select(-c(SCL_count_NA, SCL_count_0, SCL_totr)) %>% 

  # Replace NaN with NAs
  mutate(across(c(SCL_som.pn:SCL_psdi.pn), ~na_if(., "NaN"))) %>%
  
  # Move the subscales so they come immediately after the measures
  relocate(SCL_som.pn:SCL_psdi.pn, .after = SCL90.pn)

STAI: State-Trait Anxiety Inventory

Notes

General Notes

  • Speilberger et al., 1993

Scoring Instructions

SPSS Syntax Notes

  • SPSS syntax said we used state scale, only (not trait scale)

Qualtrics Scoring

Script

Rename STAI columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="STAI_State_1.pn"):which(colnames(df.pn)=="STAI_Trait_20.pn")

# Set new names (State)
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "State_", replacement = "s", x = colnames(df.pn[,cols])))

# Set new names (Trait)
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "Trait_", replacement = "t", x = colnames(df.pn[,cols])))

Reverse item scores

State Scores
# Reverse Code Key
reverse_key <- setNames(c(1:4), 4:1)

# Reverse State Score Q's 1, 2, 5, 8, 10, 11, 15, 16, 19, 20
df.pn <- df.pn %>%
  mutate_at(vars(c(STAI_s1.pn, STAI_s2.pn, STAI_s5.pn, STAI_s8.pn, STAI_s10.pn, 
                   STAI_s11.pn, STAI_s15.pn, STAI_s16.pn, STAI_s19.pn, STAI_s20.pn)),
            funs(recode(., !!!reverse_key)))

# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("STAI_s1.pn", "STAI_s2.pn", "STAI_s5.pn", "STAI_s8.pn", "STAI_s10.pn", 
                             "STAI_s11.pn", "STAI_s15.pn", "STAI_s16.pn", "STAI_s19.pn", "STAI_s20.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("STAI_s1.pn", "STAI_s2.pn", "STAI_s5.pn", "STAI_s8.pn", "STAI_s10.pn", 
                             "STAI_s11.pn", "STAI_s15.pn", "STAI_s16.pn", "STAI_s19.pn", "STAI_s20.pn")))
Trait Scores
# Reverse State Score Q's 1, 3, 6, 7, 10, 13, 14, 16, 19
df.pn <- df.pn %>%
  mutate_at(vars(c(STAI_t1.pn, STAI_t3.pn, STAI_t6.pn, STAI_t7.pn, STAI_t10.pn, 
                   STAI_t13.pn, STAI_t14.pn, STAI_t16.pn, STAI_t19.pn)),
            funs(recode(., !!!reverse_key)))

# Mark reversed scores with `_r`
setnames(x = df.pn, 
                     old = c("STAI_t1.pn", "STAI_t3.pn", "STAI_t6.pn", "STAI_t7.pn", "STAI_t10.pn", 
                             "STAI_t13.pn", "STAI_t14.pn", "STAI_t16.pn", "STAI_t19.pn"), 
                     new = gsub(pattern = ".pn", 
                          replacement = "_r.pn", 
                          x = c("STAI_t1.pn", "STAI_t3.pn", "STAI_t6.pn", "STAI_t7.pn", "STAI_t10.pn", 
                             "STAI_t13.pn", "STAI_t14.pn", "STAI_t16.pn", "STAI_t19.pn")))

Calculate summary scores

df.pn <- df.pn %>% 
  
  # Tell R that we want to take the mean across a row
  rowwise() %>%
  
  # Tell R that STAI scores are numeric
  mutate_at(vars(c(STAI_s1_r.pn:STAI_t20.pn)), as.numeric) %>%
  
  # Calculate total scores
  mutate(STAI_state.pn = sum(c_across(STAI_s1_r.pn:STAI_s20_r.pn)),
         STAI_trait.pn = sum(c_across(STAI_t1_r.pn:STAI_t20.pn))) %>%
  
  # Move the summmary scores so they come immediately after the measures
  relocate(STAI_state.pn, .after = STAI_s20_r.pn) %>%
  relocate(STAI_trait.pn, .after = STAI_t20.pn)

WIAF: What is a Father

Notes

General Notes

  • Schoppe-Sullivan, 2013
  • Though in the original SPSS syntax, Darby computed a non-traditional summary score, the current syntax will not calculate any summary score since the authors did not publish official instructions
    • Researchers should feel free to calculate their own summary score if desired

Scoring Instructions

SPSS Syntax Notes

  • We’ll compute the average of 4 “non traditional attitudes” items. Double check before using to make sure these are the right items
  • Non-traditional attitudes items were 1, 5, 7, and 11

Qualtrics Scoring

Script

Rename WIAF columns

# Get Column Numbers
cols <- which(colnames(df.pn)=="WIAF_1.pn"):which(colnames(df.pn)=="WIAF_15.pn")

# Set new names
setnames(df.pn, 
         old = colnames(df.pn[,cols]), 
         new = gsub(pattern = "_", replacement = "", x = colnames(df.pn[,cols])))

Recode WIAF values according to author scoring instructions

df.pn <- df.pn %>%
  mutate_at(vars(c(WIAF1.pn:WIAF15.pn)), 
            funs(recode(., 
                        '1' = '5',
                        '2' = '4',
                        '3' = '3',
                        '4' = '2',
                        '5' = '1')))

Finishing Up

Clean Up

df.pn <- df.pn %>%
  # Re-order Columns
  relocate(c(
    
    # Demographics
    Parent:DrugFrequency.pn,
    Born_US.pn:Insurance_Status.pn,
    Illness1.pn:Illness7_current.pn,
    
    # Inventories
    AAS1.pn:AAS_anx.pn,
    BDI1.pn:BDI_tot.pn,
    BFI1.pn:BFI_open.pn,
    COPE1.pn:COPE_blame.pn,
    DAS1.pn:DAS_tot.pn,
    ECR1.pn:ECR_avoid.pn,
    IRI1.pn:IRI_pd.pn,
    ISS1_r.pn:ISS_tot.pn,
    LAPR1.pn:LAPR_pmi.pn,
    LEC1.pn:LEC_hapwit.pn,
    LES1_hap.pn:LES_tot.pn,
    MAAS1_r.pn:PAAS_pre.pn,
    MAT1.pn:MAT_tot.pn,           
    MOS1.pn:MOS_tot.pn,           
    PAS1_r.pn:PAS_mean.pn,   
    PregSymp1_presence.pn:PregSymp_tot_distress.pn,        
    PSAM1.pn:PSAM_mean.pn,           
    PSQI1.pn:PSQI_tot.pn,
    PSS1.pn:PSS_tot.pn,
    RF1_r.pn:RF_tot.pn,           
    SCL1.pn:SCL_psdi.pn,
    STAI_s1_r.pn:STAI_trait.pn,
    WIAF1.pn:WIAF15.pn),
.after = CoupleID) %>%
  # Remove Extraneous Columns
  select(-`3`)

Create Summary File

df.pn_sum <- df.pn %>%
  select(CoupleID, Parent,
         DaysPregnant.pn:Education.pn,
         BMI.pn:Insurance_Status.pn, 
         AAS_close.pn:AAS_anx.pn,
         BDI_tot.pn, 
         BFI_ext.pn:BFI_open.pn,
         COPE_dist.pn:COPE_blame.pn,
         DAS_con.pn:DAS_tot.pn,
         ECR_anx.pn:ECR_avoid.pn,
         IRI_fs.pn:IRI_pd.pn,
         ISS_tot.pn,
         LAPR_pur.pn:LAPR_pmi.pn,
         LEC_hap.pn:LEC_hapwit.pn,
         LES_pos.pn:LES_tot.pn,
         MAAS_qual.pn:MAAS_tot.pn, PAAS_qual.pn:PAAS_tot.pn,
         MAT_tot.pn,
         MOS_emo.pn:MOS_tot.pn, 
         PAS_mean.pn, 
         PregSymp_total.pn:PregSymp_tot_distress.pn,
         PSAM_mean.pn,
         PSQI_tot.pn,
         PSS_tot.pn, 
         RF_tot.pn,
         SCL_som.pn:SCL_psdi.pn, 
         STAI_state.pn, STAI_trait.pn
         )

Write CSV Files

write.csv(df.pn, here("data/qualtrics/Final", "0_pn.total.csv"))
write.csv(df.pn_sum, here("data/qualtrics/Final", "0_pn.summary.csv"))

Write SAV Files

haven::write_sav(df.pn, here("data/qualtrics/Final", "0_pn.total.sav"))